// 封装 request

let baseurl = 'http://47.94.148.165:3001'
const ajax = (url,data,header)=>{
  // laoding
  wx.showLoading({
    title: '加载中',
  })
    return new Promise((resolve,reject)=>{
      wx.request({
        url: baseurl+url, //仅为示例，并非真实的接口地址
        data: data,
        header:header?header: {
          'content-type': 'application/json', // 默认值
          "token":localStorage.getItem('token')?localStorage.getItem('token'):null
        },
        success (res) {
          // console.log('res1',res);
          // 结束loading
          wx.hideLoading()
          // console.log(res.data)
          if(res.data.code==200){
            resolve(res.data)
          }else{
            reject(res)
          }
        },
        fail(err){
          reject(err)
        }
      })

    })
}

  


export default ajax

